use actix_web::{get, HttpResponse, post, Responder, web, Error};
use crate::model::{AppState, QueryOptions, Todo, User};
use crate::response::{ HttpResult};

#[get("/healthchecker")]
async fn health_checker_handler() -> impl Responder {
    const MESSAGE: &str = "Build Simple CRUD API with Rust and Actix Web";
    let result=&HttpResult{
        flag:true,
        code:20000,
        message:"请求数据成功!".to_string(),
        data: MESSAGE
    };
    HttpResponse::Ok().json(result)
}

#[get("/todos")]
pub async fn todos_list_handler(
    data:web::Data<AppState>,
) -> impl Responder {
 let conn=  data.pool.get().expect("Failed to get connection");
}
pub fn config(conf: &mut web::ServiceConfig) {
    let scope = web::scope("/api")
        .service(health_checker_handler)
        .service(todos_list_handler);
    conf.service(scope);
}